import os
import sys
import configparser

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)

from utils.DBHelper import DBHelper
from utils.DBHelper import logger
from apis.yq import get_yq_data


if __name__ == "__main__":
    config = configparser.ConfigParser()
    config.read("./config/db.ini")
    DBHandler = DBHelper(
        config.get("MYSQL", "host"),
        config.get("MYSQL", "user"),
        config.get("MYSQL", "pwd"),
        config.get("MYSQL", "db"),
        int(config.get("MYSQL", "port")),
    )
    table = {"address": config.get("TABLE", "address")}
    get_yq_data(DBHandler, logger, table)
    DBHandler.closeCursor()
    DBHandler.closeDB()
    print(">>> address ok!")
    print(">>> exit()")
